home *** CD-ROM | disk | FTP | other *** search
- unit Grid16U;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, Grids, DBGrids, DB, DBTables;
-
- type
- TForm1 = class(TForm)
- Table1: TTable;
- DataSource1: TDataSource;
- DBGrid1: TDBGrid;
- procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
- Field: TField; State: TGridDrawState);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
- Field: TField; State: TGridDrawState);
- begin
- with (Sender as TDBGrid) do
- begin
- { Our criteria means green cells, but if the cell is selected, }
- { stick with the default blue background but use green font }
- if Field.DataSet.FieldByName('TaxRate').AsFloat > 0 then
- if gdSelected in State then
- Canvas.Font.Color := clGreen
- else
- begin
- Canvas.Brush.Color := clGreen;
- Canvas.Font.Color := clWhite;
- end;
- DefaultDrawDataCell(Rect, Field, State)
- end
- end;
-
- end.
-